//#define __FORCE_TRACE__
//#define __FORCE_DEBUG__
//#define __FORCE_INFO__
#define THIS_FILE "fn_targetShot.sqf"
#include <core_macros.h>

TRACE_1("Start",_this);
TMFPROFILERSTART;

private ["_target","_selectionName","_damage","_shooter","_time"];
DEFAULT_PARAM(_target,0,objNull);
DEFAULT_PARAM(_selectionName,1,"");
DEFAULT_PARAM(_damage,2,0);
DEFAULT_PARAM(_shooter,3,objNull);


if (IS_OBJECT(_target) && _selectionName == "" && {_damage >= 0.005} && {!isnull _target} && {_target getVariable["IsUp",true]}) then {
	_target setVariable["IsUp",false];
	_target animate["terc", 1];
	if (!isnull (_shooter) && {isplayer _shooter}) then {
		["addScore",[_shooter,1]] call FUNC(callEvent);
	};
	if (GVAR(ShotDownTime) > 0) then {
		_target setVariable["PopUp",(Time + GVAR(ShotDownTime) + random(GVAR(ShotDownTime) / 2))];
	};
};

TRACE("End");
TMFPROFILERSTOP;
0